Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GuildChannel): regression on default channel type #5251

Merged
merged 2 commits into from
Mar 28, 2021

Conversation

almostSouji
Copy link
Member

@almostSouji almostSouji commented Jan 23, 2021

Please describe the changes this PR makes and why it should be merged:

⚠️ closes #5273

The merge of #5022 has caused a regression, which this PR aims to fix.

When no channel is provided in data the PR defaults to this.type. This is however not the required numerical for the channel type the API expects resulting in

DiscordAPIError: Invalid Form Body
type: Value "text" is not int.

The other case (type is present in data) chooses to do the defaulting through the ChannelTypes enum and uppercasing the expected text value, which I have accordingly replicated in the defaulting case.

Status

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@Koyamie
Copy link
Contributor

Koyamie commented Jan 28, 2021

Shouldn't we still use this.type if no new type is sent to the data object ?

I was thinking about this:

type: ChannelTypes[(data.type || this.type).toUpperCase()],

@almostSouji
Copy link
Member Author

almostSouji commented Jan 28, 2021

Not required, has no benefit: https://discord.com/developers/docs/resources/channel#modify-channel

All JSON parameters are optional.

Aka: you just need to pass what you actually want to edit, meaning undefined (which this will otherwise result in) is valid

@Koyamie
Copy link
Contributor

Koyamie commented Jan 28, 2021

Not required, has no benefit: https://discord.com/developers/docs/resources/channel#modify-channel

All JSON parameters are optional.

Aka: you just need to pass what you actually want to edit, meaning undefined (which this will otherwise result in) is valid

Alright, thanks 👍

kyranet
kyranet previously requested changes Feb 1, 2021
src/structures/GuildChannel.js Show resolved Hide resolved
src/structures/GuildChannel.js Outdated Show resolved Hide resolved
@almeidx
Copy link
Member

almeidx commented Feb 15, 2021

You mentioned this pull request instead of the #5273 issue in the pull request description

@WilcoSp
Copy link

WilcoSp commented Mar 4, 2021

it would be better if instead of using uppercased channel type name to use instead an integer that discord uses to represent a type https://discord.com/developers/docs/resources/channel#channel-object-channel-types

this how it looks for my own quick fix but off course for the library it would be better to map each type to an integer
afbeelding

note: I only use the function to mass change permissions when a server owner changes the verify channel for my verification bot

@almostSouji
Copy link
Member Author

almostSouji commented Mar 4, 2021

it would be better if instead of using uppercased channel type name to use instead an integer

This is out of scope of this regression fix - we might do so going forward, as mentioned by vlad above:

You could argue we don't support numbers as types, but that should come if we ever replace string types with numbers

@iCrawl iCrawl merged commit e7c4f36 into discordjs:master Mar 28, 2021
@almostSouji almostSouji deleted the reg-channeltype branch April 6, 2021 20:19
@iCrawl iCrawl added this to the Version 13 milestone Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error using GuildChannel.setTopic()
10 participants